//
//  HNSH_SearchFriendsCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/17.
//

#import "HNSH_SearchFriendsCell.h"

@interface HNSH_SearchFriendsCell ()
/** 图片 */
@property (nonatomic, strong)UIImageView * imgView;
/**  */
@property (nonatomic, strong)UILabel * nameLabel;
/** 图片 */
@property (nonatomic, strong)UIImageView * rightImgView;
@end

@implementation HNSH_SearchFriendsCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addAllViews];
        [self addAllLayout];
    }
    return self;
}

- (void)setModel:(HNSH_SearchFriendsModel *)model {
    _model = model;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:[UIImage imageNamed:@"base_user_header_icon"]];
    self.nameLabel.text = model.name;
}

//MARK: Cycle Methods
- (void)addAllViews{
    self.backgroundColor = [UIColor appWhiteLabelColor];
    [self.contentView addSubview:self.imgView];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.rightImgView];
}

- (void)addAllLayout{
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(32);
        make.width.height.mas_equalTo(38);
        make.centerY.mas_equalTo(self.contentView);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.height.mas_equalTo(self.contentView);
        make.left.mas_equalTo(self.imgView.mas_right).offset(11);
        make.right.mas_equalTo(-100);
    }];
    [self.rightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.width.height.mas_equalTo(12);
        make.centerY.mas_equalTo(self.imgView);
    }];
}

//MARK: Getter Methods
- (UIImageView *)imgView{
    if (!_imgView) {
        _imgView = [UIImageView new];
        _imgView.layer.cornerRadius = 8;
        _imgView.layer.masksToBounds = YES;
    }
    return _imgView;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.textColor = [UIColor appBlackLabelColor];
        _nameLabel.font = [UIFont systemFontOfSize:16];
    }
    return _nameLabel;
}

- (UIImageView *)rightImgView{
    if (!_rightImgView) {
        _rightImgView = [UIImageView new];
        _rightImgView.image = [UIImage imageNamed:@"base_nav_show_right"];
    }
    return _rightImgView;
}

@end
